package client;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

import java.util.ArrayList;

import client.Talk;


/**
 *
 * @author tomek
 */
public class panels extends JFrame {

    JTabbedPane tabbedPane = new JTabbedPane();
    
    public panels() {
        super("History");
        
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        
        String[] t = new String[5];
        t[0] = "[10:10:10] <Tytus> aaa asdad adasd ad ada";
        t[1] = "bbb";
        t[2] = "cccbbb";
        t[3] = "dddbbb";
        t[4] = "eeebbb";
        
        
        for(int i = 0; i < 5; i++) {
            JPanel p = createPanel(t);
            tabbedPane.addTab("Tomek-Tytus", p);
            //tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
            
        }
        //Add the tabbed pane to this panel.
        add(tabbedPane);
        
        //The following line enables to use scrolling tabs.
        tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
//        
//        
    
    }
    
    public JPanel createPanel(String[] t) {
        
        JPanel panel = new JPanel();
        
        JTextArea textArea = new JTextArea();
        String[] messages = t;
        
        textArea.setEditable(false);
        textArea.setFont(new Font("Serif", Font.ITALIC, 14));
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        
        
        for(int i = 0; i < 30; i++) {
            textArea.append(messages[0]+"\n");
        }
        
        JScrollPane areaScrollPane = new JScrollPane(textArea);
        areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        areaScrollPane.setPreferredSize(new Dimension(650, 350));
        
        panel.add(areaScrollPane);
        
        return panel;
    }
    
    public static void showGui() {
        panels p = new panels();
        p.pack();
        p.setVisible(true);
    }

    public static void main(String[] args) {
       javax.swing.SwingUtilities.invokeLater(new Runnable() {public void run(){showGui();}}); 
    }
    
}
